﻿// models/book.js
const { DataTypes } = require("sequelize");
const sequelize = require("../db");
const Category = require("./category");

const Book = sequelize.define(
  "Book",
  {
    bookId: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    // categoryId: {
    //   type: DataTypes.INTEGER,
    //   references: {
    //     model: Category,
    //     key: "categoryId",
    //   },
    // },
    bookName: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    author: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    description: {
      type: DataTypes.STRING,
    },
  },
  {
    underscored: true,
  },
);

// Book.belongsTo(Category, { foreignKey: "category_id" });

module.exports = Book;
